<form nz-form *ngIf="ready" (ngSubmit)="create()" novalidate>
    <nz-row>
        <nz-col [nzSpan]="10">
            <nz-form-item>
                <nz-form-label *ngIf="!disableLabel">Add a repository manager</nz-form-label>
                <nz-form-control>
                    <nz-select [(ngModel)]="selectedRepoId" [nzDisabled]="connectLoading" name="repo">
                        <nz-option *ngFor="let r of reposManagerList; let i = index;" [nzValue]="i" [nzLabel]="r"></nz-option>
                    </nz-select>
                </nz-form-control>
            </nz-form-item>
        </nz-col>
        <nz-col [nzSpan]="2" [nzOffset]="12">
            <nz-form-item>
                <nz-form-item>
                    <button nz-button nzType="primary" type="submit" [disabled]="selectedRepoId == null"  [nzLoading]="connectLoading" name="addrepo">
                        Connect
                    </button>
                </nz-form-item>
            </nz-form-item>
        </nz-col>
    </nz-row>
</form>
<nz-modal nzTitle="{{ 'repoman_modal_verif_title' | translate }}" [nzVisible]="repoModalVisible" (nzOnCancel)="repoModalVisible = false">
    <div *nzModalContent>
        <form nz-form>
            <ng-container *ngIf="addRepoResponse?.auth_type === 'basic'">
                <nz-form-item>
                    <nz-form-label>Username</nz-form-label>
                    <nz-form-control>
                        <input nz-input type="text" name="first-name" placeholder="Username" [(ngModel)]="basicUser">
                    </nz-form-control>
                </nz-form-item>
                <nz-form-item>
                    <nz-form-label>Password</nz-form-label>
                    <nz-form-control>
                        <input nz-input type="password" name="last-name" placeholder="Password" [(ngModel)]="basicPassword">
                    </nz-form-control>
                </nz-form-item>
            </ng-container>
            <ng-container *ngIf="addRepoResponse?.auth_type === 'oauth'">
                <p>
                    {{ 'repoman_modal_verif_text' | translate}}
                    <a href="{{addRepoResponse?.url}}" target="_blank">{{ 'common_click_here' | translate}}</a>
                </p>
                <nz-form-item  *ngIf="selectedRepoId != null">
                    <nz-form-label>Verification code</nz-form-label>
                    <nz-form-control>
                        <input nz-input type="text" name="verifiercode" placeholder="{{ 'repoman_modal_verif_code_placeholder' | translate }}" [(ngModel)]="validationToken">
                    </nz-form-control>
                </nz-form-item>
            </ng-container>
        </form>
    </div>
    <div *nzModalFooter>
        <button nz-button name="cancel" (click)="repoModalVisible = false">Cancel</button>
        <ng-container *ngIf="addRepoResponse?.auth_type === 'basic'">
            <button nz-button nzType="primary" name="validationbtn" [nzLoading]="verificationLoading" (click)="sendBasicAuth()">Validate</button>
        </ng-container>
        <ng-container *ngIf="selectedRepoId != null">
            <button nz-button nzType="primary" name="validationbtn" [nzLoading]="verificationLoading" (click)="sendVerificationCode()">Validate</button>
        </ng-container>
    </div>
</nz-modal>
